package com.example.factory.responsibility.slot;

import com.example.factory.responsibility.Context;
import com.example.factory.responsibility.ResourceWrapper;
import lombok.Data;

@Data
public abstract class AbstractLinkedProcessorSlot<T> implements ProcessorSlot<T>{
    private AbstractLinkedProcessorSlot<?> next = null;

    @Override
    public void fireEntry(Context context, ResourceWrapper wrapper,  Object param) {
        if (next != null) {
            next.transFormEntry(context,wrapper,param);
        }
    }

    public void transFormEntry(Context context, ResourceWrapper wrapper, Object param){
        T t = (T)param;
        entry(context,wrapper,t);
    }

    @Override
    public void fireExit(Context context, ResourceWrapper wrapper,  Object param) {
        if (next != null) {
            next.exit(context, wrapper, param);
        }
    }
}
